package com.cdream.basic.util;

import cn.hutool.core.util.NumberUtil;

import java.math.BigDecimal;

public class NumberUtilExample {
    public static void main(String[] args) {
        System.out.println(0.2D+0.1D);
        System.out.println(new BigDecimal(0.2F).add(BigDecimal.valueOf(0.1F)));
        System.out.println(NumberUtil.add(0.2D, 0.1D));
        System.out.println(NumberUtil.add(new BigDecimal(0.2D), BigDecimal.valueOf(0.1D)));
        System.out.println(NumberUtil.div(1,3.0D));
        System.out.println(1/3D);
        //System.out.println(new BigDecimal(String.valueOf(1D)).divide(new BigDecimal(String.valueOf(3D))));
        System.out.println(new BigDecimal("1").divide(new BigDecimal("3"),2,BigDecimal.ROUND_DOWN));

        // 计算BigDecimal先将double/float转换为字符串
        // 做除法的时候加个scale
    }

}
